package com.token.sysflow.action;
import com.alibaba.fastjson.JSON;
import com.token.base.FuncUtil;
import com.token.base.Pl;
import com.token.sql.IntegrateSql;
import com.token.sysflow.impl.AbstractFlowHandlerImpl;
import com.token.sysflow.impl.GetPathApproverImpl;

/**
 * @author chenjianxiong 2020/4/12
 */
public class GetPathApproverAction extends AbstractFlowAction {
    @Override
    protected void publicParameter(FuncUtil f, AbstractFlowHandlerImpl handler) throws Exception {
        //操作时间
        handler.setActionTimer(Pl.getCurDataTime());

        //操作用户
        handler.setActionUser(f.getEffectiveUserName());

        //租户Id
        handler.setSysId(Pl.getSysId());
    }
    public void executeAction(FuncUtil f,IntegrateSql iSql) throws Exception{
        GetPathApproverImpl handler = new GetPathApproverImpl();
        String keyUnid = f.getUrlQueryString("keyUnid");

        //起草第一次提交时
        if(keyUnid == null || "".equals(keyUnid)){
            handler.setFlowId(f.getUrlQueryString("flowId", true, "流程Id[flowId]"));
            handler.setApplyer(f.getUrlQueryString("applyer",true,"申请人[applyer]"));
            handler.setCreater(f.getUrlQueryString("creater",true,"起草人[creater]"));
            handler.setStepId(f.getUrlQueryString("stepId")); //环节ID不传时，默认取开始环节。
        }else{
            handler.setKeyUnid(keyUnid);
        }
        handler.setFieldValues(JSON.parseObject(f.getUrlQueryString("fieldValues")));
        this.start(f,iSql,handler);
    }
}
